package com.zzxx.wechat.dao;

import com.baomidou.mybatisplus.extension.service.IService;
import com.zzxx.wechat.common.enums.ArcteryxSpuStatusEnum;
import com.zzxx.wechat.entity.ArcteryxProduct;
import com.zzxx.wechat.mapper.ArcteryxProductMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ArcteryxProductDao extends ServiceImpl<ArcteryxProductMapper, ArcteryxProduct> implements IService<ArcteryxProduct> {


    public List<ArcteryxProduct> queryByNos(List<String> productNos) {
        return lambdaQuery()
                .in(ArcteryxProduct::getProductNo, productNos)
                .eq(ArcteryxProduct::getIsDel, false)
                .list();
    }

    public ArcteryxProduct queryByNo(String productNo) {
        return lambdaQuery()
                .eq(ArcteryxProduct::getProductNo, productNo)
                .eq(ArcteryxProduct::getIsDel, false)
                .one();
    }


    public boolean saveByNoColor(String productNo, String color) {
        ArcteryxProduct arcteryxProduct = new ArcteryxProduct();
        arcteryxProduct.setProductNo(productNo);
        arcteryxProduct.setColor(color);
        return save(arcteryxProduct);

    }


    public boolean deleteById(Integer id) {

        ArcteryxProduct updateArcteryxProduct = new ArcteryxProduct();
        updateArcteryxProduct.setId(id);
        updateArcteryxProduct.setIsDel(true);
        return updateById(updateArcteryxProduct);
    }

    public List<ArcteryxProduct> queryByStatus(ArcteryxSpuStatusEnum spuStatusEnum) {
        return lambdaQuery()
                .in(ArcteryxProduct::getStatusCode, spuStatusEnum.getCode())
                .eq(ArcteryxProduct::getIsDel, false)
                .list();
    }
}
